<template>
    <div class="demo-collapse">
        <el-collapse v-model="activeNames" @change="handleChange">
            <el-collapse-item title="问题描述" name="des">
                <div class="detail">
                    <img class="image" src="../../../../../assets/二分查找/二分查找.jpeg">
                    <div class="detail-text">
                        <div class="text">
                            二分查找算法是一种在有序数组中查找某一特定元素的搜索算法，
                            其思想就是不断地将有序查找表“一分为二”，逐渐缩小搜索区域，进而找到目标元素。
                        </div>
                        <el-table :data="tableData" border style="width: 99%;">
                            <el-table-column prop="name" label="名称" />
                            <el-table-column prop="time" label="时间复杂度(平均)" />
                            <el-table-column prop="timeBest" label="时间复杂度(最好)" />
                        </el-table>
                    </div>
                </div>
            </el-collapse-item>
            <el-collapse-item title="相关研究" name="3">
                <ul>
                    <li v-for="item in thesisData" :key="item.title">
                        <a :href="item.link" target="_blank">
                            <div class="thesis">
                                <img class="thesis-cover" src="../../../../../icons//thesis.svg" alt="">
                                <div class="thesis-title">
                                    {{ item.title }}
                                </div>
                                <div class="thesis-author">
                                    <span>作者：</span>{{ item.author }}
                                </div>
                                <div class="thesis-time">
                                    <span>时间：</span>{{ item.time }}
                                </div>
                                <div class="thesis-source">
                                    <span>来源：</span>{{ item.source }}
                                </div>
                            </div>
                        </a>
                    </li>
                </ul>
            </el-collapse-item>
            <el-collapse-item title="应用场景" name="4">
                <div class="detail">
                    <img class="use" src="../../../../../assets/二分查找/二分查找2.jpg" alt="">
                    <div class="text">
                        在实际应用中，有5种典型问题非常适合二分查找，分别是：
                        在有序无重复数据的数组中查找等于给定值的元素；
                        在有序有重复数据的数组中查找第一个值等于给定值的元素；
                        在有序有重复数据的数组中查找最后一个值等于给定值的元素；
                        在有序无重复数据的数组中查找第一个大于等于给定值的元素；
                        在有序无重复数据的数组中查找最后一个小于等于给定值的元素；
                        另外，对于循环有序数组也可以用二分法查找。
                    </div>
                </div>
            </el-collapse-item>
        </el-collapse>
    </div>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
const activeNames = ref(['1'])
const handleChange = (val: string[]) => {
    console.log(val)
}

// 相关研究部分
const thesisData = [
    {
        title: "多索引二分查找方法的研究与实现",
        author: "甄超，邸海涛，赵益民，李康",
        time: "2020年",
        source: "百度学术",
        link: "https://xueshu.baidu.com/usercenter/paper/show?paperid=1e7r04s0n7050v60426402u00y075087&site=xueshu_se",
    },
    {
        title: "在数据结构中如何使用二分查找",
        author: "田华娟",
        time: "2005年",
        source: "百度学术",
        link: "https://xueshu.baidu.com/usercenter/paper/show?paperid=cbca551556cef879b804a55cd9f33192&site=xueshu_se",
    },
    {
        title: "【二分查找】详细图解",
        author: "Charon_cc",
        time: "2022年",
        source: "CSDN",
        link: "https://blog.csdn.net/qq_45978890/article/details/116094046?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522170806744216777224437090%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=170806744216777224437090&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~top_positive~default-1-116094046-null-null.142^v99^control&utm_term=%E4%BA%8C%E5%88%86%E6%9F%A5%E6%89%BE&spm=1018.2226.3001.4187",
    },

]

// 复杂度表格描述
const tableData = [
    {
        name: '二分查找',
        time: 'O(logn)',
        timeBest:'O(1)',
    },
]
</script>

<style scoped lang="scss">
* {
    list-style: none;
}

.image {
    width: 290px;
    border-radius: 10px;
    margin-right: 10px;
}

a {
    text-decoration: none;
    /* 去除默认的下划线 */
    outline: none;
    /* 去除旧版浏览器的点击后的外虚线框 */
    color: #000;
    /* 去除默认的颜色和点击后变化的颜色 */
}

.detail {
    display: flex;
    justify-content: center;
    align-items: end;

    .detail-box {
        display: flex;
        flex-direction: column;
    }

    .text {
        margin-left: 10px;
        margin-bottom: 10px;
        cursor: default;
    }

    .use {
        width: 240px;
        height: 150px;
        border-radius: 10px;
    }
}

// 相关研究部分
.thesis {
    width: 98%;
    position: relative;
    left: 20px;
    margin-bottom: 10px;
    font-weight: normal;
    background: #F5F5F5;
    border-radius: 10px;
    transition: all 0.2s linear;

    .thesis-title {
        position: absolute;
        top: 0;
        left: 5px;
    }

    .thesis-author {
        position: absolute;
        top: 25px;
        left: 120px;
    }

    .thesis-time {
        position: absolute;
        top: 45px;
        left: 120px;
    }

    .thesis-source {
        position: absolute;
        top: 65px;
        left: 120px;
    }

    &:hover {
        cursor: pointer;
        transform: translateX(-15px);
    }
}
</style>